<template>
  <div class="videcontent">
    <div><van-search disabled placeholder="请输入搜索关键词" /></div>
    <div class="vido_box">
      <van-tabs @change="oncange" v-model="active" swipeable animated>
        <van-tab
          v-for="item in typeList"
          :key="item.id"
          :name="item.id"
          :title="item.name"
        >
          <van-empty
            v-if="videoList.length == 0"
            image="https://sss-1306551685.cos.ap-guangzhou.myqcloud.com/MobileShop/zanwu.png"
            description="该类别暂无数据"
          />

          <!-- <my-list  :videoList="videoList"></my-list> -->
          <div class="vide_content">
            <div class="vide_item" v-for="item in videoList" :key="item.vidID">
              <div class="vide_top">
                <router-link
                  :to="{ name: 'videDetail', params: { vid: item.vidID } }"
                >
                  <div v-if="item.Cover != ''">
                    <img
                      style="border-radius: 10px"
                      v-lazy="videoUrl + item.Cover"
                      alt=""
                    />
                  </div>

                  <video v-else :src="videoUrl + item.item.Cover"></video>
                </router-link>
              </div>
              <p class="vide_title">
                <van-tag
                  style="margin-right: 6px"
                  v-if="item.MediaType == '视频'"
                  plain
                  color="#7232dd"
                  >视频</van-tag
                >{{ item.message }}
              </p>
              <div class="vide_bottom">
                <!-- 头像与昵称 -->
                <div class="tip_l">
                  <img src="../../assets/images/k.png" alt="" />
                  <span>万能青年</span>
                </div>
                <!-- 点赞 -->
                <div class="tip_r">
                  <van-icon
                    name="like-o"
                    size="18"
                    @click="likeClick"
                    :color="num ? '#F1050A' : ''"
                  />
                  <transition
                    @before-enter="beforeEnter"
                    @enter="enter"
                    @after-enter="afterEnter"
                  >
                    <span class="addOne" v-if="isLike">+1</span>
                  </transition>

                  {{ num }}
                </div>
              </div>
            </div>
          </div>
        </van-tab>
      </van-tabs>
      <div style="height: 1.8rem" class="fbox"></div>
    </div>
  </div>
</template>
<script>
export default {
  props: { videoList: Array },
  data() {
    return {
      active: "1",
      typeList: [
        { id: 1, name: "全部" },
        { id: 2, name: "穿搭" },
        { id: 3, name: "家具" },
        { id: 4, name: "数码" },
        { id: 5, name: "美食" },
        { id: 6, name: "美妆" },
        { id: 7, name: "科技" },
        { id: 8, name: "生活" },
      ],
      loading: false,
      finished: false,

      totol: 0,
      page_num: 1,
      start: 1,
      num: "22", //点赞数
      isLike: false,
    };
  },
  created() {},
  mounted() {},
  activated() {},
  methods: {
    oncange(name, title) {
      this.selectVideolist(title);
    },
    async selectVideolist(title) {
      const { data: res } = await this.$http.get("queryVideolist", {
        params: { type: title },
      });
      console.log(res);
      this.videoList = res.data;
    },

    beforeEnter(el) {
      //动画开始进入前
      el.style.transform = "translate(0,0)";
    },
    enter(el, done) {
      //动画执行时
      el.offsetWidth;
      el.style.transform = "translate(5px,-20px)";
      el.style.transition = "all 0.6s ease";
      done();
    },
    afterEnter(el) {
      //动画结束时
      this.isLike = !this.isLike;
    },
    likeClick() {
      this.isLike = true;
      this.num++;
    },
  },
};
</script>
<style lang="less" scoped>
.videcontent {
  background: #fff;
}
.vido_box {
  //   border: 1px solid red;
  //   padding: 10px;
}
.vide_content {
  overflow: hidden;
  column-count: 2;
  .vide_item {
    width: 100%;
    -moz-column-break-inside: avoid;
    break-inside: avoid;
    box-sizing: border-box;
    padding: 5px;
    /* margin: 5px; */
    margin-bottom: 10px;
    box-shadow: 1px 2px 5px 2px #eaeaea;
    background: white;
    border-radius: 10px;
  }
  .vide_top {
    // background: black;
    border-radius: 10px;
    video {
      width: 100%;
      height: 100%;
      border-radius: 10px;
    }
  }
  .vide_title {
    height: 2rem;
    font-size: 0.9rem;
    padding-top: 0.5rem;
    color: #1a1a1a;
    line-height: 1.3rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    padding: 6px;
    /* padding-bottom: 12px; */
    margin-bottom: 10px;
  }
  .vide_bottom {
    margin-bottom: 26px;
    padding: 1px;
  }
  .tip_l {
    float: left;
    display: flex;
    align-items: center;
    img {
      width: 25px;
      height: 25px;
      border-radius: 50%;
    }
    span {
      margin-left: 3px;
    }
  }
  .tip_r {
    margin-top: 5px;
    float: right;
    display: flex;
    align-items: center;
    .van-rate {
      width: 20px;
      height: 20px;
      border-radius: 50%;
    }
    span {
      margin-left: 3px;
      color: #bcbbbb;
    }
  }
}
</style>